import os
import zipfile

def get_zip_structure(zip_path):
    """
    获取zip文件的内容结构字符串（类似tree的输出）
    
    参数:
        zip_path (str): zip文件路径
        
    返回:
        str: 类似tree的结构字符串
    """
    structure = []
    with zipfile.ZipFile(zip_path, 'r') as zip_ref:
        # 获取所有文件并按目录结构排序
        files = sorted(zip_ref.namelist())
        
        # 构建目录树
        dir_tree = {}
        for file in files:
            parts = file.split('/')
            current_level = dir_tree
            for part in parts[:-1]:
                if part not in current_level:
                    current_level[part] = {}
                current_level = current_level[part]
            if parts[-1]:  # 不是空字符串（目录）
                current_level[parts[-1]] = None
        
        # 递归生成tree结构
        def build_tree(tree, prefix=''):
            keys = sorted(tree.keys())
            for i, key in enumerate(keys):
                if i == len(keys) - 1:
                    new_prefix = prefix + '    '
                    line_prefix = '└── '
                else:
                    new_prefix = prefix + '│   '
                    line_prefix = '├── '
                
                structure.append(prefix + line_prefix + key)
                if tree[key] is not None:
                    build_tree(tree[key], new_prefix)
        
        # 从根目录开始构建
        root_name = os.path.splitext(os.path.basename(zip_path))[0]
        structure.append(f'./{root_name}')
        build_tree(dir_tree)
    
    return '\n'.join(structure)
